/*
 *  Copyright (c) 2022 ZhuHai Jieli Technology Co.,Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef APP_CONFIG_H
#define APP_CONFIG_H

#define CONFIG_DEBUG_ENABLE

#define CONFIG_APP_SPP_LE                 1
#define CONFIG_APP_MULTI                  0
#define CONFIG_APP_DONGLE                 0
#define CONFIG_APP_CENTRAL                0
#define CONFIG_APP_LL_SYNC                0
#define CONFIG_APP_BEACON                 0
#define CONFIG_APP_NONCONN_24G            0
#define CONFIG_APP_TUYA                   0
#define CONFIG_APP_AT_COM                 0
#define CONFIG_APP_AT_CHAR_COM            0
#define CONFIG_APP_IDLE                   0
#define CONFIG_APP_CONN_24G               0

#if CONFIG_APP_SPP_LE
#define DOUBLE_BT_SAME_NAME                0
#define DOUBLE_BT_SAME_MAC                 0
#define CONFIG_APP_SPP_LE_TO_IDLE          0

#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_GATT_SERVER_NUM          1
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_DONGLE
#define EDR_EMITTER_EN                     0

#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        1
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_COMPOSITE_EQUIPMENT      0
#define CONFIG_BT_GATT_SERVER_NUM          0
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_CENTRAL
#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_GATT_SERVER_NUM          0
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_MULTI
#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_GATT_SERVER_NUM          1
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_AT_COM
#define TRANS_AT_COM                       1
#define TRANS_AT_CLIENT                    0

#define CONFIG_BT_GATT_COMMON_ENABLE       0
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_GATT_SERVER_NUM          1
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_AT_CHAR_COM
#define CONFIG_BT_GATT_COMMON_ENABLE       0
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_GATT_SERVER_NUM          1
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_TUYA
#define DOUBLE_BT_SAME_NAME                0

#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          0
#define CONFIG_BT_GATT_SERVER_NUM          1
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_LL_SYNC
#define DOUBLE_BT_SAME_NAME                0

#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          0
#define CONFIG_BT_GATT_SERVER_NUM          1
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#elif CONFIG_APP_CONN_24G

#define CONFIG_BT_GATT_COMMON_ENABLE       1
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          1
#define CONFIG_BT_GATT_SERVER_NUM          0
#define CONFIG_BT_GATT_CONNECTION_NUM      (CONFIG_BT_GATT_SERVER_NUM + CONFIG_BT_GATT_CLIENT_NUM)

#else
#define CONFIG_BT_GATT_COMMON_ENABLE       0
#define CONFIG_BT_SM_SUPPORT_ENABLE        0
#define CONFIG_BT_GATT_CLIENT_NUM          0
#define CONFIG_BT_GATT_SERVER_NUM          0
#define CONFIG_BT_GATT_CONNECTION_NUM      0

#endif

#if CONFIG_BT_GATT_CONNECTION_NUM > 8
#error "SUPPORT MAX IS 8 !!!"
#endif

#include "btcontroller_mode.h"

#define APP_PRIVATE_PROFILE_CFG

#if (CONFIG_BT_MODE == BT_NORMAL)
#define TCFG_NORMAL_SET_DUT_MODE                  0

#else

#undef  TCFG_BD_NUM
#define TCFG_BD_NUM                                  1

#undef  TCFG_USER_TWS_ENABLE
#define TCFG_USER_TWS_ENABLE                      0

#undef  TCFG_USER_BLE_ENABLE
#define TCFG_USER_BLE_ENABLE                      1

#undef  TCFG_AUTO_SHUT_DOWN_TIME
#define TCFG_AUTO_SHUT_DOWN_TIME                  0

#undef  TCFG_SYS_LVD_EN
#define TCFG_SYS_LVD_EN                              0

#undef  TCFG_LOWPOWER_LOWPOWER_SEL
#define TCFG_LOWPOWER_LOWPOWER_SEL                0

#undef TCFG_AUDIO_DAC_LDO_VOLT
#define TCFG_AUDIO_DAC_LDO_VOLT                DACVDD_LDO_2_65V

#undef TCFG_LOWPOWER_POWER_SEL
#define TCFG_LOWPOWER_POWER_SEL                PWR_LDO15

#undef  TCFG_PWMLED_ENABLE
#define TCFG_PWMLED_ENABLE                    DISABLE_THIS_MOUDLE

#undef  TCFG_ADKEY_ENABLE
#define TCFG_ADKEY_ENABLE                   DISABLE_THIS_MOUDLE

#undef  TCFG_IOKEY_ENABLE
#define TCFG_IOKEY_ENABLE                    DISABLE_THIS_MOUDLE

#undef TCFG_TEST_BOX_ENABLE
#define TCFG_TEST_BOX_ENABLE                0

#undef TCFG_AUTO_SHUT_DOWN_TIME
#define TCFG_AUTO_SHUT_DOWN_TIME            0

#undef TCFG_POWER_ON_NEED_KEY
#define TCFG_POWER_ON_NEED_KEY                0

#undef TCFG_UART0_ENABLE
#define TCFG_UART0_ENABLE                    DISABLE_THIS_MOUDLE

#endif

#define BT_FOR_APP_EN                     0

#if CONFIG_APP_OTA_ENABLE
#define RCSP_BTMATE_EN                    1
#define RCSP_UPDATE_EN                    1
#define UPDATE_MD5_ENABLE                 0
#else
#define RCSP_BTMATE_EN                    0
#define RCSP_UPDATE_EN                    0
#define UPDATE_MD5_ENABLE                 0
#endif

#ifdef CONFIG_SDFILE_ENABLE
#define SDFILE_DEV                "sdfile"
#define SDFILE_MOUNT_PATH         "mnt/sdfile"

#if (USE_SDFILE_NEW)
#define SDFILE_APP_ROOT_PATH           SDFILE_MOUNT_PATH"/app/"
#define SDFILE_RES_ROOT_PATH           SDFILE_MOUNT_PATH"/res/"
#else
#define SDFILE_RES_ROOT_PATH           SDFILE_MOUNT_PATH"/C/"
#endif

#endif
#if TCFG_USER_EDR_ENABLE
#if RCSP_BTMATE_EN
#define CONFIG_BT_RX_BUFF_SIZE  (3 * 512)
#define CONFIG_BT_TX_BUFF_SIZE  (3 * 512)
#else
#define CONFIG_BT_RX_BUFF_SIZE  (5 * 512)
#define CONFIG_BT_TX_BUFF_SIZE  (5 * 512)
#endif
#else
#define CONFIG_BT_RX_BUFF_SIZE  (0)
#define CONFIG_BT_TX_BUFF_SIZE  (0)
#endif

#if (CONFIG_BT_MODE != BT_NORMAL)
#undef  CONFIG_BT_TX_BUFF_SIZE
#define CONFIG_BT_TX_BUFF_SIZE  (6 * 1024)

#endif
#define BT_NORMAL_HZ                CONFIG_BT_NORMAL_HZ

#define BT_NORMAL_HZ                CONFIG_BT_NORMAL_HZ
#define BT_CONNECT_HZ               CONFIG_BT_CONNECT_HZ

#define BT_A2DP_HZ                    CONFIG_BT_A2DP_HZ
#define BT_TWS_DEC_HZ                CONFIG_TWS_DEC_HZ

#define BT_CALL_HZ                    CONFIG_BT_CALL_HZ
#define BT_CALL_ADVANCE_HZ          CONFIG_BT_CALL_ADVANCE_HZ
#define BT_CALL_16k_HZ                CONFIG_BT_CALL_16k_HZ
#define BT_CALL_16k_ADVANCE_HZ      CONFIG_BT_CALL_16k_ADVANCE_HZ

#define CONFIG_UPDATE_JUMP_TO_BT_UPDATA   1
#if CONFIG_UPDATE_JUMP_TO_BT_UPDATA 
#define UPDATE_SUPPORT_JUMP_BT_UPDATA
#ifdef UPDATE_SUPPORT_JUMP_BT_UPDATA
#define  BOOT_SPI_GET_PORT_FUNC  1
#if (defined CONFIG_CPU_BR23) || (defined CONFIG_CPU_BR25)
#define CPU_A        2
#define CPU_B        3
#else
#define CPU_A        0
#define CPU_B        1
#endif 

#if (defined CONFIG_CPU_BD19) || (defined CONFIG_CPU_BD29)
#undef BOOT_SPI_GET_PORT_FUNC
#define  BOOT_SPI_GET_PORT_FUNC  0
#endif

#define     BOOT_SPI_NORFLASH_PORTA   BIT(CPU_A)
#define     BOOT_SPI_NORFLASH_PORTB   BIT(CPU_B)
#endif
#endif

#if (defined(CONFIG_CPU_BR23) || defined(CONFIG_CPU_BR25) || defined(CONFIG_CPU_BD29) || defined(CONFIG_CPU_BD19))
#define USER_UART_UPDATE_ENABLE           0

#define UART_UPDATE_SLAVE    0
#define UART_UPDATE_MASTER    1

#define UART_UPDATE_RX_PORT               IO_PORTA_02
#define UART_UPDATE_TX_PORT               IO_PORTA_03

#define UART_UPDATE_ROLE    UART_UPDATE_SLAVE

#if USER_UART_UPDATE_ENABLE
#undef TCFG_CHARGESTORE_ENABLE
#undef TCFG_TEST_BOX_ENABLE
#define TCFG_CHARGESTORE_ENABLE                DISABLE_THIS_MOUDLE
#endif

#endif

#define FLOW_CONTROL           0

#define TCFG_USER_TWS_ENABLE                      0
#define TCFG_USER_BLE_ENABLE                      1
#define TCFG_USER_EDR_ENABLE                      0

#define USER_SUPPORT_PROFILE_SPP    0
#define USER_SUPPORT_PROFILE_HFP    0
#define USER_SUPPORT_PROFILE_A2DP   0
#define USER_SUPPORT_PROFILE_AVCTP  0
#define USER_SUPPORT_PROFILE_HID    0
#define USER_SUPPORT_PROFILE_PNP    0
#define USER_SUPPORT_PROFILE_PBAP   0

#if(TCFG_USER_TWS_ENABLE || TCFG_USER_BLE_ENABLE)
#define TCFG_BD_NUM                               1
#define TCFG_AUTO_STOP_PAGE_SCAN_TIME             0
#else
#define TCFG_BD_NUM                               1
#define TCFG_AUTO_STOP_PAGE_SCAN_TIME             0
#endif

#define BT_INBAND_RINGTONE                        0
#define BT_PHONE_NUMBER                           0
#define BT_SUPPORT_DISPLAY_BAT                    0
#define BT_SUPPORT_MUSIC_VOL_SYNC                 0

#endif
